package cn.satoken.common;

import cn.dev33.satoken.stp.SaTokenInfo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.ArrayList;
import java.util.List;

/**
 * <h3>saToken</h3>
 * <p>扩展返回信息</p>
 *
 * @author gdw
 * @since 2025-04-21 11:33:44
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class TokenInfo extends SaTokenInfo {

    private Long userId;
    private List<String> roles;
    private List<Router>  menus;

    public TokenInfo(SaTokenInfo info) {
        this.setTokenName(info.getTokenName());
        this.setTokenValue(info.getTokenValue());
        this.setLoginId(info.getLoginId());
        this.setIsLogin(info.getIsLogin());
        this.setLoginType(info.getLoginType());
        this.setTokenTimeout(info.getTokenTimeout());
        this.setSessionTimeout(info.getSessionTimeout());
        this.setTokenSessionTimeout(info.getTokenSessionTimeout());
        this.setTokenActiveTimeout(info.getTokenActiveTimeout());
        this.setLoginDeviceType(info.getLoginDeviceType());
        this.setTag(info.getTag());
    }

    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    public static class Menu {
        private String path;
        private String name;
        private String title;
        private String icon;
    }
    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    public static class Router {
        private String id;
        private String title;
        private String path;
        private String name;
        private String icon;
        List<Menu> children;
    }
}
